:root {
  /* Dark theme variables (default) */
  --background: #000000;
  --foreground: #e5e5e5;
  --primary: #8b5cf6;
  --primary-foreground: #ffffff;
  --primary-hover: #7c3aed;
  --secondary: #2d2d2d;
  --secondary-foreground: #e5e5e5;
  --secondary-hover: #3f3f46;
  --muted: #2d2d2d;
  --muted-foreground: #a1a1aa;
  --muted-hover: #3f3f46;
  --accent: #2d2d2d;
  --accent-foreground: #e5e5e5;
  --accent-hover: #3f3f46;
  --border: #3f3f46;
  --border-hover: #52525b;
  --input: #3f3f46;
  --input-hover: #52525b;
  --input-focus: #6366f1;
  --card: #1e1e1e;
  --card-foreground: #e5e5e5;
  --card-hover: #2d2d2d;
  --shadow: rgba(0, 0, 0, 0.3);
  --shadow-hover: rgba(0, 0, 0, 0.4);
  --shadow-focus: rgba(139, 92, 246, 0.3);
  --filter-tag: #2d2d2d;
  --filter-tag-text: #e5e5e5;
  --filter-tag-close: #a1a1aa;
  --filter-tag-close-hover: #ffffff;
  --star-color: #fbbf24;
  --radius: 0.5rem;
  --transition: all 0.2s ease-in-out;
  --font-weight-normal: 400;
  --font-weight-medium: 500;
  --font-weight-semibold: 600;
  --font-weight-bold: 700;
}

html.light-theme {
  /* Light theme variables */
  --background: #ffffff;
  --foreground: #1f2937;
  --primary: #7c3aed;
  --primary-foreground: #ffffff;
  --primary-hover: #6d28d9;
  --secondary: #f3f4f6;
  --secondary-foreground: #1f2937;
  --secondary-hover: #e5e7eb;
  --muted: #f9fafb;
  --muted-foreground: #6b7280;
  --muted-hover: #f3f4f6;
  --accent: #f3f4f6;
  --accent-foreground: #1f2937;
  --accent-hover: #e5e7eb;
  --border: #e5e7eb;
  --border-hover: #d1d5db;
  --input: #f9fafb;
  --input-hover: #f3f4f6;
  --input-focus: #7c3aed;
  --card: #ffffff;
  --card-foreground: #1f2937;
  --card-hover: #f9fafb;
  --shadow: rgba(0, 0, 0, 0.1);
  --shadow-hover: rgba(0, 0, 0, 0.15);
  --shadow-focus: rgba(124, 58, 237, 0.3);
  --filter-tag: #e5e7eb;
  --filter-tag-text: #374151;
  --filter-tag-close: #9ca3af;
  --filter-tag-close-hover: #1f2937;
  --star-color: #f59e0b;
  --success: #059669;
  --warning: #d97706;
  --error: #dc2626;
  --info: #2563eb;
}

/* Base Styles */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: "Inter", sans-serif;
  background-color: var(--background);
  color: var(--foreground);
  line-height: 1.6;
  font-size: 16px;
  font-weight: var(--font-weight-normal);
  transition: var(--transition);
}

.container {
  width: 100%;
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 1rem;
}

a {
  text-decoration: none;
  color: var(--primary);
  transition: var(--transition);
}

a:hover {
  color: var(--primary-hover);
}

a:focus {
  outline: 2px solid var(--input-focus);
  outline-offset: 2px;
  border-radius: var(--radius);
}

ul {
  list-style: none;
}

img {
  max-width: 100%;
  height: auto;
  display: block;
}

/* Button Styles */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius);
  font-weight: var(--font-weight-medium);
  font-size: 0.875rem;
  padding: 0.5rem 1rem;
  cursor: pointer;
  transition: var(--transition);
  border: none;
  gap: 0.5rem;
  text-decoration: none;
  font-family: inherit;
}

.btn:focus {
  outline: 2px solid var(--input-focus);
  outline-offset: 2px;
}

.btn-primary {
  background-color: var(--primary);
  color: var(--primary-foreground);
  border: 1px solid var(--primary);
}

.btn-primary:hover {
  background-color: var(--primary-hover);
  border-color: var(--primary-hover);
  transform: translateY(-1px);
  box-shadow: 0 4px 8px var(--shadow);
}

.btn-outline {
  background-color: transparent;
  color: var(--foreground);
  border: 1px solid var(--border);
}

.btn-outline:hover {
  background-color: var(--muted);
  border-color: var(--border-hover);
  color: var(--foreground);
}

.btn-sm {
  padding: 0.375rem 0.75rem;
  font-size: 0.75rem;
}

/* Page Header */
.page-header {
  padding: 2rem 0;
  text-align: center;
  border-bottom: 1px solid var(--border);
  background-color: var(--background);
}

.page-header h1 {
  font-size: 2rem;
  font-weight: var(--font-weight-bold);
  margin-bottom: 0.5rem;
  color: var(--foreground);
}

.page-header p {
  color: var(--muted-foreground);
  max-width: 600px;
  margin: 0 auto;
  font-size: 1rem;
  line-height: 1.6;
}

/* Filter Section */
.filter-section {
  padding: 1.5rem 0;
  border-bottom: 1px solid var(--border);
  background-color: var(--background);
}

.filter-container {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  align-items: flex-start;
  margin-bottom: 1rem;
}

#filter-reset {
  margin-top: 0.5rem;
  align-self: flex-start;
}

.filter-group {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.filter-group label {
  font-size: 0.875rem;
  font-weight: var(--font-weight-medium);
  color: var(--muted-foreground);
  white-space: nowrap;
}

.filter-select {
  padding: 0.5rem 2rem 0.5rem 0.75rem;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background-color: var(--input);
  color: var(--foreground);
  font-size: 0.875rem;
  font-family: inherit;
  appearance: none;
  cursor: pointer;
  transition: var(--transition);
  min-width: 120px;
}

.filter-select:hover {
  border-color: var(--border-hover);
  background-color: var(--input-hover);
}

.filter-select:focus {
  outline: 2px solid var(--input-focus);
  outline-offset: 2px;
  border-color: var(--input-focus);
}

.active-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 1rem;
}

.filter-tag {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.375rem 0.75rem;
  border-radius: 9999px;
  background-color: var(--filter-tag);
  color: var(--filter-tag-text);
  font-size: 0.75rem;
  font-weight: var(--font-weight-medium);
  border: 1px solid var(--border);
  transition: var(--transition);
}

.filter-tag:hover {
  background-color: var(--muted-hover);
  border-color: var(--border-hover);
}

.filter-tag.category-tag {
  background-color: var(--primary);
  color: var(--primary-foreground);
  border-color: var(--primary);
}

.filter-tag.category-tag:hover {
  background-color: var(--primary-hover);
  border-color: var(--primary-hover);
}

.filter-tag-close {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 1rem;
  height: 1rem;
  border-radius: 50%;
  background-color: var(--filter-tag-close);
  color: var(--primary-foreground);
  font-size: 0.625rem;
  cursor: pointer;
  transition: var(--transition);
  font-weight: var(--font-weight-bold);
}

.filter-tag-close:hover {
  background-color: var(--filter-tag-close-hover);
  transform: scale(1.1);
}

/* Series Grid */
.series-grid-section {
  padding: 2rem 0;
  background-color: var(--background);
}

.series-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.75rem;
}

.series-card {
  display: flex;
  flex-direction: column;
  background-color: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  transition: var(--transition);
  cursor: pointer;
}

.series-card:hover {
  box-shadow: 0 8px 16px var(--shadow-hover);
  transform: translateY(-4px);
  border-color: var(--border-hover);
  background-color: var(--card-hover);
}

.series-card:focus-within {
  outline: 2px solid var(--input-focus);
  outline-offset: 2px;
}

.series-image {
  width: 100%;
  aspect-ratio: 3 / 4;
  overflow: hidden;
  position: relative;
}

.series-image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: var(--transition);
}

.series-card:hover .series-image img {
  transform: scale(1.05);
}

.series-info {
  padding: 0.5rem;
  flex: 1;
  display: flex;
  flex-direction: column;
}

.series-title {
  font-size: 0.875rem;
  font-weight: var(--font-weight-semibold);
  color: var(--foreground);
  margin-bottom: 0.25rem;
  line-height: 1.3;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  transition: var(--transition);
}

.series-card:hover .series-title {
  color: var(--primary);
}

.series-description {
  font-size: 0.75rem;
  color: var(--muted-foreground);
  margin-bottom: 0.5rem;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  line-height: 1.4;
  flex: 1;
}

.series-meta {
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
  margin: 0.25rem 0;
}

.series-author,
.series-rating {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  font-size: 0.75rem;
  color: var(--muted-foreground);
  transition: var(--transition);
}

.series-rating .fa-star {
  color: var(--star-color);
}

.series-stats {
  display: flex;
  justify-content: space-between;
  font-size: 0.75rem;
  color: var(--muted-foreground);
  margin-bottom: 0.5rem;
  gap: 0.5rem;
}

.series-stats span {
  display: flex;
  align-items: center;
  gap: 0.25rem;
}

.series-genres {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem;
  margin-top: auto;
}

.badge {
  display: inline-block;
  padding: 0.125rem 0.375rem;
  border-radius: var(--radius);
  font-size: 0.625rem;
  font-weight: var(--font-weight-medium);
  background-color: var(--secondary);
  color: var(--secondary-foreground);
  border: 1px solid var(--border);
  transition: var(--transition);
}

.badge:hover {
  background-color: var(--secondary-hover);
  border-color: var(--border-hover);
}

.badge-secondary {
  background-color: var(--secondary);
  color: var(--secondary-foreground);
}

.series-card.filtered-in {
  animation: fadeIn 0.3s ease-out forwards;
}

.series-card.filtered-out {
  display: none;
}

/* Pagination */
.pagination {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 0.5rem;
  margin-top: 2rem;
}

.pagination-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 2.5rem;
  height: 2.5rem;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background-color: var(--background);
  color: var(--foreground);
  font-size: 0.875rem;
  font-weight: var(--font-weight-medium);
  cursor: pointer;
  transition: var(--transition);
  text-decoration: none;
}

.pagination-btn:hover {
  background-color: var(--muted);
  border-color: var(--border-hover);
  transform: translateY(-1px);
  box-shadow: 0 2px 4px var(--shadow);
}

.pagination-btn:focus {
  outline: 2px solid var(--input-focus);
  outline-offset: 2px;
}

.pagination-btn.active {
  background-color: var(--primary);
  color: var(--primary-foreground);
  border-color: var(--primary);
}

.pagination-btn.active:hover {
  background-color: var(--primary-hover);
  border-color: var(--primary-hover);
}

.pagination-ellipsis {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 2.5rem;
  height: 2.5rem;
  color: var(--muted-foreground);
  font-weight: var(--font-weight-medium);
}

/* Dropdown Styles */
.dropdown-container {
  position: relative;
  display: inline-block;
}

.dropdown-toggle {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-width: 150px;
  padding-right: 2rem;
  background-color: var(--input);
  transition: var(--transition);
}

.dropdown-toggle:hover {
  background-color: var(--input-hover);
  border-color: var(--border-hover);
}

.dropdown-toggle:focus {
  outline: 2px solid var(--input-focus);
  outline-offset: 2px;
  border-color: var(--input-focus);
}

.dropdown-toggle::after {
  content: "";
  position: absolute;
  right: 0.75rem;
  top: 50%;
  transform: translateY(-50%);
  width: 0.8rem;
  height: 0.8rem;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%236b7280' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: center;
  background-size: contain;
  transition: var(--transition);
}

html.light-theme .dropdown-toggle::after {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%236b7280' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
}

html:not(.light-theme) .dropdown-toggle::after {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%23a1a1aa' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
}

.dropdown-container.open .dropdown-toggle::after {
  transform: translateY(-50%) rotate(180deg);
}

.dropdown-menu {
  position: absolute;
  top: 100%;
  left: 0;
  z-index: 10;
  display: none;
  min-width: 250px;
  padding: 0.75rem;
  margin-top: 0.25rem;
  background-color: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 8px 16px var(--shadow);
  transition: var(--transition);
}

.dropdown-container.open .dropdown-menu {
  display: block;
  animation: fadeIn 0.2s ease-out;
}

.categories-container {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.5rem;
  max-height: 200px;
  overflow-y: auto;
  margin-bottom: 0.75rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--border);
}

.category-item {
  display: flex;
  align-items: center;
  gap: 0.375rem;
  padding: 0.25rem;
  border-radius: var(--radius);
  transition: var(--transition);
}

.category-item:hover {
  background-color: var(--muted);
}

.category-checkbox {
  accent-color: var(--primary);
  width: 1rem;
  height: 1rem;
  cursor: pointer;
}

.category-item label {
  font-size: 0.875rem;
  cursor: pointer;
  color: var(--foreground);
  font-weight: var(--font-weight-normal);
  transition: var(--transition);
  flex: 1;
}

.category-item:hover label {
  color: var(--primary);
}

.dropdown-actions {
  display: flex;
  justify-content: space-between;
  gap: 0.5rem;
}

/* Custom select elements */
.custom-select {
  position: relative;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%236b7280' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.5rem center;
  transition: var(--transition);
}

html.light-theme .custom-select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%236b7280' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
}

html:not(.light-theme) .custom-select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%23a1a1aa' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
}

/* Animation for filtered items */
@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* No results message */
.no-results {
  text-align: center;
  padding: 3rem 0;
  color: var(--muted-foreground);
  background-color: var(--background);
}

.no-results h3 {
  font-size: 1.5rem;
  font-weight: var(--font-weight-semibold);
  margin-bottom: 1rem;
  color: var(--foreground);
}

.no-results p {
  margin-bottom: 1.5rem;
  color: var(--muted-foreground);
}

/* Media Queries */
@media (min-width: 640px) {
  .series-grid {
    grid-template-columns: repeat(3, 1fr);
    gap: 1rem;
  }

  .series-info {
    padding: 0.75rem;
  }

  .series-title {
    font-size: 1rem;
  }

  .series-description {
    font-size: 0.875rem;
  }

  .series-author,
  .series-rating {
    font-size: 0.875rem;
  }

  .series-stats {
    font-size: 0.875rem;
  }

  .badge {
    padding: 0.25rem 0.5rem;
    font-size: 0.75rem;
  }
}

@media (min-width: 768px) {
  .series-grid {
    grid-template-columns: repeat(3, 1fr);
  }

  .filter-container {
    flex-wrap: nowrap;
    align-items: center;
  }
}

@media (min-width: 1024px) {
  .series-grid {
    grid-template-columns: repeat(4, 1fr);
    gap: 1.5rem;
  }

  .series-info {
    padding: 1rem;
  }
}

@media (max-width: 640px) {
  .dropdown-menu {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    width: 100%;
    max-width: none;
    margin-top: 0.25rem;
    border-radius: var(--radius);
    box-shadow: 0 8px 24px var(--shadow-hover);
    z-index: 100;
    max-height: 70vh;
    overflow-y: auto;
  }

  .dropdown-container {
    position: relative;
    width: 100%;
  }

  .dropdown-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0, 0, 0, 0.3);
    z-index: 99;
    display: none;
    transition: var(--transition);
  }

  .dropdown-overlay.show {
    display: block;
  }

  .filter-container {
    gap: 0.75rem;
    flex-direction: column;
    align-items: stretch;
  }

  .filter-group {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.25rem;
    width: 100%;
  }

  .filter-select {
    min-width: 100%;
    width: 100%;
  }

  .dropdown-toggle {
    width: 100%;
    min-width: 100%;
  }

  .categories-container {
    grid-template-columns: 1fr;
    max-height: 50vh;
  }
}

@media (max-width: 640px) {
  .filter-section {
    padding: 1rem 0;
  }

  .page-header {
    padding: 1.5rem 0;
  }

  .page-header h1 {
    font-size: 1.75rem;
  }

  .page-header p {
    font-size: 0.875rem;
    padding: 0 1rem;
  }
}

/* Focus styles for accessibility */
*:focus {
  outline: 2px solid var(--input-focus);
  outline-offset: 2px;
}

button:focus,
select:focus,
input:focus {
  outline: 2px solid var(--input-focus);
  outline-offset: 2px;
}

/* High contrast mode support */
@media (prefers-contrast: high) {
  :root {
    --border: #666666;
    --shadow: rgba(0, 0, 0, 0.5);
  }

  html.light-theme {
    --border: #333333;
    --shadow: rgba(0, 0, 0, 0.3);
  }
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
  * {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
